﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/MyLayout.cshtml";
}
 
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="~/Content/bootstrap/css/style.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/base.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-2.1.1.min.js"></script>
    <script src="~/Scripts/layer/layer.js"></script>
    <script src="~/Scripts/layPage/laypage.js"></script>
    <link href="~/Scripts/css/gloabcss.css" rel="stylesheet" />
    <style>
        input {
            height: 25px;
            margin-left: 15px;
        }

        .span8 input {
            width: 30%;
        }

        .container-fluid {
            margin: 0;
            padding: 0;
        }

        #edit_agency p {
            padding-top: 15px;
        }

        table tr td {
            padding: 12px 0px 12px 0px;
        }

        #Paging {
            position: absolute;
            float: right;
            left: 60%;
            margin-top: 4%;
        }
    </style>
 <script type="text/javascript">
     var hiden_type = 1;
     //窗体加载
     $(function () {
          
         SearchList();
        
     })
     //分页
     function SearchList() {
         var pagecount = queryts(1, 8);
         //好像很实用的样子，后端的同学再也不用写分页逻辑了。
         laypage({
             cont: 'pager',
             pages: pagecount, //可以叫服务端把总页数放在某一个隐藏域，再获取。假设我们获取到的是18
             skip: true, //是否开启跳页
             skin: '#5c86b2',
             curr: function () { //通过url获取当前页，也可以同上（pages）方式获取
                 var page = location.search.match(/page=(\d+)/);
                 return page ? page[1] : 1;
             }(),
             jump: function (e, first) { //触发分页后的回调
                 if (e.pages > 1) { $('#pagercount').html('共' + e.pages + '页'); } else { $('#pagercount').hide(); }
                 $('.laypage_skip').val(e.curr);
                 if (!first) { //一定要加此判断，否则初始时会无限刷新
                     queryts(e.curr, 8);
                 }
             }
         });
     }
     //模糊查询
     function queryts(pageindex, pagesize) {
         var pagecount;
         
         $.ajax({
             type: "GET",
             url: "/admin715/Book/query_book",
             data: { "pageindex": pageindex, "pagesize": pagesize},
             dataType: "json",
             async: false,
             success: function (data) {
                 $("#tab_product  tr:not(:first)").remove();
                 if (data.MessageCode == "0") {
                     // layer.alert(JSON.stringify(data));
                     pagecount = data.Pagecount;
                     if (data.BookList != null) {
                         if (hiden_type == 1) {
                             $.each(data.BookList, function (i, n) {

                                 var html = "<tr class='rep-tab-tr1 back-f9f'>" +
                                     "<td>" + n.ID + "</td>" +
                                     "<td>" + n.s7 + "</td>" +
                                     "<td>" + n.s8 + "</td>" +
                                     "<td>" + n.s1 + "</td>" +
                                       "<td>" + n.s2 + "</td>" +
                                       
                                           "<td>" + n.s4 + "</td>" +
                                     "<td style=\"text-align:left;\"><input type='button' value='回复' onclick='Opeas(" + n.ID + ",\"edit\")' style='width:20%;height:22px;margin-left:5px;cursor:pointer; border:none;color:#55AC58;'/></td></tr>";
                                 $("#tab_product").append(html);
                             });
                         } else {
                             $.each(data.BookList, function (i, n) {
                                 var html = "<tr class='rep-tab-tr1 back-f9f'>" +
                                     "<td>" + n.ID + "</td>" +
                                     "<td>" + n.s7 + "</td>" +
                                     "<td>" + n.s8 + "</td>" +
                                     "<td>" + n.s1 + "</td>" +
                                       "<td>" + n.s2 + "</td>" +
                                        
                                           "<td>" + n.s4 + "</td>" +
                                        "<td style=\"text-align:left;\"></td></tr>";

                                 $("#tab_product").append(html);
                             });
                         }
                     } else {
                         layer.msg("暂无数据");
                     }
                 } else {
                     layer.msg("查询失败，请稍后再试！");
                 }
             }
         })
         return pagecount;
     }

     //刷新当前页面
     function reLoad() {
         window.location.reload();
     }
     function Opeas(id,opea) {
         if (opea == "edit") {
             
             GetBook(id);
         } else {
 
         }
         var me = opea == "edit" ? "修改" : "添加";
         layer.open({
             type: 1,
             btn: ['确定', '取消'],
             title: '' + me + '回复信息',
             skin: "layui-layer-molv",
             area: ['400px', '330px'],
             shade: 0.3,
             content: $('#edit_account'),
             btn1: function () {
                 if (CheckInputNullAll("edit_account")) {
                     var rebook = $("#txt_rebook").val();
                     
                     $.ajax({
                         type: "POST",
                         url: "/admin715/Book/OpeaBook",
                         dataType: "json",
                         data: { "id": id, "opea": opea, "rebook": rebook },
                         success: function (data) {
                             //  layer.alert(JSON.stringify(data));
                             if (data.MessageCode == "0") {
                                 layer.msg(opea == "add" ? "添加成功" : "修改成功!");
                                 setTimeout(function () {
                                     window.location.reload();
                                 }, 2000)
                             } else if (data.MessageCode == "50") {
                                 layer.msg("信息重复!");
                             } else {
                                 layer.msg(opea == "add" ? "添加失败" : "修改失败!");

                             }
                         }
                     });
                 }
             },
             btn2: function () {
                  
                 layer.close();
             }
         })
     }

     //查询出要编辑的人的信息
     function GetBook(id) {
        
         $.ajax({
             type: "GET",
             url: "/admin715/Book/GetBook",
             data: { "id": id },
             dataType: "json",
             success: function (data) {
                 $("#txt_s7").val(data.model.s7);
                 $("#txt_s8").val(data.model.s8);
                 $("#txt_rebook").val(data.model.rebook);
             }
         });
     }
 </script>
<div class="rightoverflow">
    <div class="ove-hid">
        <div class="wid-100 cor-4d4 fon-siz20 lin-hei60 bor-bot999">
            <div class="flo-lef">&nbsp;&nbsp;&nbsp;&nbsp;<span><i class="fa fa-gear"></i></span><span>投诉管理</span></div>
        </div>
    </div>
    <div class="ove-hid">
        <div class="wid-120 cor-4d4 fon-siz20 lin-hei60 bor-botdcd ">
        </div>
    </div>
    <div class="ove-hid">
        <div class="Rep-main wid-100 mag-top50">
            
            <div class="pro-div" id="con_two_1">
                <table class="rep-tab wid-100 cor-4d4 tex-ali" id="tab_product">
                    <thead>
                        <tr>
                            <td>id</td>
                            <td>类型</td>
                            <td>内容</td>
                            <td>姓名</td>
                            <td>称谓</td>
                            
                            <td>手机号</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>
 <div id="edit_account" style="display:none;">

    <div class="divLeft" style="height:50px;" id="top_two"> <div class="divSpan" style="line-height:25px;"><span>类型:</span></div><div class="divInput"><input type="text" id="txt_s7" placeholder="请输入名称" class="required" /></div></div>
     <div class="divLeft" style="height:50px;" id="top_two"> <div class="divSpan" style="line-height:25px;"><span>内容:</span></div><div class="divInput"><input type="text" id="txt_s8" placeholder="请输入名称" class="required" /></div></div>

      <div class="divLeft" style="height:50px;"> <div class="divSpan" style="line-height:25px;"><span>回复:</span></div><div class="divInput"><input type="text" id="txt_rebook" multiple="multiple" placeholder="请输入代码" class="required" style="width:70%;" /></div></div>

</div>
<div id="Paging">
    <span id="pagercount" style="float:left "></span>
    <div id="pager" class="pager" style="float:left">
    </div>
</div>



